<%@ page pageEncoding="UTF-8" %>
<link  href="/images/favicon.ico?cache=<%=Math.random()%>" rel="shortcut icon" type="image/x-icon">
<script src="http://cdn.bootcss.com/vue/1.0.26-csp/vue.min.js"></script>
<div class="top_nav ui_bg_dark" id="page_header">
<!--导航-->
    <%
        List<String> hospitalSkinList = Arrays.asList("business");
        String skin = "txzj";
        if (session.getAttribute("user") != null) {
            Object user = (Object)session.getAttribute("user");
            if (user instanceof ManageUser) {
                skin = Tools.getDesc(((ManageUser) user).getSkin(), "default");
            }
        }
        // 小产品的头部
        if (hospitalSkinList.contains(skin)) {
%>
    <div class="top_nav_cont">
        <div class="top_nav_logo">
            <span>后台管理系统</span>
        </div>
        <div class="top_nav_logo_right">
            <div class="user_container" onclick="changePassword()">
                <%
                    try {
                %>
                <span>${user.hospitalName}的${user.name}</span>
                <%
                    }
                    catch (Exception e) {
                %>
                <span>${user.name}</span>
                <%
                    }
                %>
                <span>${user_role}</span>
                <img class="nav_password" src="/images/palace/arrow-down.png">
            </div>
            <div class="nav_quit" onclick="quit()">
                <img class="" src="/images/palace/logout.png" alt="">
            </div>
        </div>
    </div>
    <script>
        function changePassword() {
            location.href = "/palace/user/change_password.jsp";
        }
    </script>
<%
  //  }else if(true){
    }else if ("txzj".equals(skin)) {
%>
    <div class="top_nav_cont">
        <div class="top_nav_logo">
            <img src="/images/txzj/head_logo.png">
            <span>天下专家随访管理系统</span>
        </div>
        <div class="top_nav_logo_right">
            <span><img src="../../images/txzj/man_one.png"></span>
            <span>欢迎您，</span>
            <span>${user.name}</span>
            <span class="nav_quit" onclick="quit()"><img class="nav_exit" src="../../images/txzj/exit.png"></span>
        </div>
    </div>
<%
            // 公众版的头部
        } else {
%>
    <div class="top_nav_cont">
        <div class="top_nav_logo">
            <img src="/images/logo-web.png">
            <span>天下布医 ● 医院管理平台</span>
        </div>
        <div class="top_nav_logo_right">
            <span>${user.name},您好!</span>
            <%try {%>
            <span >${user.hospitalName}</span>
            <%} catch (Exception e) {

            }%>
            <span>${user_role}</span>

            <span class="nav_quit" onclick="quit()">退出</span>

            <%-- <span class="change_skin" id="green">切换皮肤</span>
            <div class="different_color">
                <div class="change_blue"  @click="changeBlue()"></div>
                <div class="change_green" @click="changeGreen()"></div>
            </div> --%>
        </div>
    </div>
<%
        }
%>
</div>
 <%-- 页面通用方法 --%>
<script>
    var hasHospitalPower = Object.create(Object.prototype, {
        hospitalId: {
            value: <%=(Integer)session.getAttribute("hospital")%>,
            writable: false,
            configurable: false,
        },
        txbyId: {
            value: 999,
            writable: false,
            configurable: false,
        },
        nowHospital: {
            set: function(val) {
                this._nowHospital = val;
                window.sessionStorage.setItem("nowHospital", JSON.stringify(val));
            },
            get: function() {
                return this._nowHospital || {
                    name: "天下布医",
                    hospital_id: 999,
                };
            }
        },
        power: {
            value: function() {
                return this.hospitalId === this.txbyId;
            },
            writable: false,
            configurable: false,
        },
        parms: {
            writable: false,
            configurable: false,
            value: function(parms) {
                if (this.power()) {
                    return Object.assign(parms, {hospital_id: this.nowHospital.hospital_id});
                } else {
                    return parms;
                }
            }
        }
    });
    if (hasHospitalPower.power()) {
        var _nowHospital = window.sessionStorage.getItem("nowHospital");
        if (_nowHospital) {
            hasHospitalPower.nowHospital = JSON.parse(_nowHospital);
        }

    }
    // 跳转，存参数
    function locationHerf(url, parms) {
        if (parms) {
            var query = window.sessionStorage.getItem("eeesys-manage") || "{}";
            query = JSON.parse(query);
            query[url] = parms;
            window.sessionStorage.setItem("eeesys-manage", JSON.stringify(query));
        }
        location.href = url + ".jsp";
    }
    // 替换页面
    function locationReplace(url, parms) {
        if (parms) {
            var query = window.sessionStorage.getItem("eeesys-manage") || "{}";
            query = JSON.parse(query);
            query[url] = parms;
            window.sessionStorage.setItem("eeesys-manage", JSON.stringify(query));
        }
        location.replace(url + ".jsp");
    }
    // 存参数
    function saveParmsHerf(url, parms) {
        if (parms) {
            var query = window.sessionStorage.getItem("eeesys-manage") || "{}";
            query = JSON.parse(query);
            query[url] = parms;
            window.sessionStorage.setItem("eeesys-manage", JSON.stringify(query));
        }
    }
    // 取参数
    function getHrefParms(url) {
        var query = window.sessionStorage.getItem("eeesys-manage") || "{}";
        query = JSON.parse(query);
        var parms = query[url];
        return parms;
    }
    // 去参数
    function clearHrefParms(url) {
        var query = window.sessionStorage.getItem("eeesys-manage") || "{}";
        query = JSON.parse(query);
        if (query[url]) {
            delete query[url];
            window.sessionStorage.setItem("eeesys-manage", JSON.stringify(query));
        }
    }
    // 去所有的参数
    function clearAllHrefParms() {
        window.sessionStorage.removeItem("eeesys-manage");
    }
</script>
<script>
    jQuery.cookie = function(name, value, options) {
        if (typeof value != 'undefined') { // name and value given, set cookie
            options = options || {};
            if (value === null) {
                value = '';
                options.expires = -1;
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                var date;
                if (typeof options.expires == 'number') {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                } else {
                    date = options.expires;
                }
                expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
            }
            var path = options.path ? '; path=' + options.path : '';
            var domain = options.domain ? '; domain=' + options.domain : '';
            var secure = options.secure ? '; secure' : '';
            document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
        } else { // only name given, get cookie
            var cookieValue = null;
            if (document.cookie && document.cookie != '') {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i ++) {
                    var cookie = jQuery.trim(cookies[i]);
                    // Does this cookie string begin with the name we want?
                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }
    };
    $(function() {
        var cookie_style = $.cookie("mystyle");
        if (cookie_style == null || cookie_style == 'default') {
            $("link[title='default']").removeAttr("disabled");
        } else {
            $("link[title='green']").removeAttr("disabled");
            $("link[title='default']").attr("disabled","disabled");
        }
    })
    function quit() {
        if (confirm("确认退出？")) {
            location.href="/quit.jsp";
        }
    }
</script>
